/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.frogs.model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author gabrielbran
 */
@Entity
@Table(name = "SUBCATEGORIA", catalog = "frogs", schema = "")
@NamedQueries({
    @NamedQuery(name = "Subcategoria.findAll", query = "SELECT s FROM Subcategoria s"),
    @NamedQuery(name = "Subcategoria.findByEmpresa", query = "SELECT s FROM Subcategoria s WHERE s.subcategoriaPK.empresa = :empresa"),
    @NamedQuery(name = "Subcategoria.findByCategoria", query = "SELECT s FROM Subcategoria s WHERE s.subcategoriaPK.categoria = :categoria"),
    @NamedQuery(name = "Subcategoria.findByCodigo", query = "SELECT s FROM Subcategoria s WHERE s.subcategoriaPK.codigo = :codigo"),
    @NamedQuery(name = "Subcategoria.findByNombre", query = "SELECT s FROM Subcategoria s WHERE s.nombre = :nombre"),
    @NamedQuery(name = "Subcategoria.findByFecha", query = "SELECT s FROM Subcategoria s WHERE s.fecha = :fecha"),
    @NamedQuery(name = "Subcategoria.findByEstatus", query = "SELECT s FROM Subcategoria s WHERE s.estatus = :estatus")})
public class Subcategoria implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected SubcategoriaPK subcategoriaPK;
    @Basic(optional = false)
    @Column(name = "nombre", nullable = false, length = 45)
    private String nombre;
    @Basic(optional = false)
    @Column(name = "fecha", nullable = false)
    @Temporal(TemporalType.DATE)
    private Date fecha;
    @Basic(optional = false)
    @Column(name = "estatus", nullable = false, length = 45)
    private String estatus;
    @JoinColumns({
        @JoinColumn(name = "empresa", referencedColumnName = "empresa", nullable = false, insertable = false, updatable = false),
        @JoinColumn(name = "categoria", referencedColumnName = "codigo", nullable = false, insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private Categoria categoria1;

    public Subcategoria() {
    }

    public Subcategoria(SubcategoriaPK subcategoriaPK) {
        this.subcategoriaPK = subcategoriaPK;
    }

    public Subcategoria(SubcategoriaPK subcategoriaPK, String nombre, Date fecha, String estatus) {
        this.subcategoriaPK = subcategoriaPK;
        this.nombre = nombre;
        this.fecha = fecha;
        this.estatus = estatus;
    }

    public Subcategoria(int empresa, int categoria, int codigo) {
        this.subcategoriaPK = new SubcategoriaPK(empresa, categoria, codigo);
    }

    public SubcategoriaPK getSubcategoriaPK() {
        return subcategoriaPK;
    }

    public void setSubcategoriaPK(SubcategoriaPK subcategoriaPK) {
        this.subcategoriaPK = subcategoriaPK;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    public String getEstatus() {
        return estatus;
    }

    public void setEstatus(String estatus) {
        this.estatus = estatus;
    }

    public Categoria getCategoria1() {
        return categoria1;
    }

    public void setCategoria1(Categoria categoria1) {
        this.categoria1 = categoria1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (subcategoriaPK != null ? subcategoriaPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Subcategoria)) {
            return false;
        }
        Subcategoria other = (Subcategoria) object;
        if ((this.subcategoriaPK == null && other.subcategoriaPK != null) || (this.subcategoriaPK != null && !this.subcategoriaPK.equals(other.subcategoriaPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.frogs.model.Subcategoria[subcategoriaPK=" + subcategoriaPK + "]";
    }

}
